package cn.zyjblogs.netty.inoutbound;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;

import java.util.List;

/**
 * 编码
 */
public class MyLongTOByteEncoder extends MessageToByteEncoder<Long> {
    /**
     *  编码
     * @param ctx 上下文
     * @param msg 消息
     * @param out
     * @throws Exception
     */
    @Override
    protected void encode(ChannelHandlerContext ctx, Long msg, ByteBuf out) throws Exception {
        System.out.println("MyLongTOByteEncoder encoder 被调用 编码");
        System.out.println("msg= "+msg);
        out.writeLong(msg);
    }
}
